<!DOCTYPE html>
<!--suppress ThymeleafVariablesResolveInspection-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="Responsive Admin Dashboard Template">
        <meta name="keywords" content="admin,dashboard">
        <meta name="author" content="skcats">
		<title></title>
		<link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all" />
        <link th:href="@{/assets/plugins/bootstrap/css/bootstrap.min.css}" rel="stylesheet">
        <link th:href="@{/assets/plugins/font-awesome/css/font-awesome.min.css}" rel="stylesheet">
        <link th:href="@{/assets/css/custom.css}" rel="stylesheet">
	</head>
	<style>
     ::-webkit-scrollbar {display:none}/*隐藏横向滚动条但可以滚动*/
     .layui-table-page {
         text-align: center;
     }

     .utable .layui-laypage .layui-laypage-curr .layui-laypage-em {
         background-color: #1E9FFF;
     }
     .layui-input-inline{margin-left: 50px;}
     .layui-form-item{margin-top: 20px;}
     .layui-form-label{width: 80px;}
     .layui-table-view thead th {
         text-align: center;
         font-weight: bold;
     }
     .layui-table-view tbody td {
         text-align: center;
     }
	</style>
<body>
<!--数据表格样式及附件-->
<script id="toolbarDemo" type="text/html">
    <div class="layui-btn-container">
        <button id="return" class="layui-btn layui-btn-sm"><i class="layui-icon"style="font-size: 20px">&#xe65c;</i></button>
        <button id="echarts" class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe62c;图表</i></button>
    </div>
</script>

<input id="replyid" type="hidden" th:value="${replyid}"/>

<!--表格-->
<div class="utable">
    <table class="layui-table" id="tab" lay-filter="tab"></table>
</div>

</body>
<script th:src="@{/assets/plugins/jquery/jquery-3.1.0.min.js}"></script>
<script th:src="@{/layui/layui.js}"></script>
<script type="text/javascript" th:inline="none">

    layui.use('table', function () {
        var table = layui.table;
        var replyid = $("#replyid").val();
        //方法渲染
        table.render({
            elem: '#tab'
            ,id: 'tab'
            ,height: 560
            ,width: 1250
            ,url: '/classreply/studata?replyid='+replyid//数据接口
            ,page: true //开启分页
            ,toolbar: '#toolbarDemo'
            ,cols: [[ //表头
                {field: 'srid', title: '编号', sort: true}
                ,{field: 'stuname', title: '学生名称'}
                ,{field: 'score1', title: '功能完善50',edit:true}
                ,{field: 'score2', title: '技术难度10',edit:true}
                ,{field: 'score3', title: '界面完美10',edit:true}
                ,{field: 'score4', title: '回答问题10',edit:true}
                ,{field: 'score5', title: '演示方法10',edit:true}
                ,{field: 'score6', title: '语言表达10',edit:true}
                ,{field: 'score7', title: '总分100',sort: true}
                ,{field: 'remark', title: '备注',edit:true}
            ]]
        });


        //点击添加iframe窗方法
        $("#return").on('click',function(){
            document.location.href="/skip/classreplylist"
        })

        $("#echarts").on('click',function(){
            document.location.href="/skip/stureplychart?id="+replyid;
        })

        //监听单元格编辑（修改）
        table.on('edit(tab)', function(obj){
            var tr = obj.tr;
            // 单元格编辑之前的值
            var oldtext = $(tr).find("td[data-field='"+obj.field+"'] div").text();
            var value = obj.value //得到修改后的值
                ,data = obj.data //得到所在行所有键值
                ,field = obj.field; //得到字段

            if (isNaN(data.score1) || isNaN(data.score2) ||
                isNaN(data.score3) || isNaN(data.score4) ||
                isNaN(data.score5) || isNaN(data.score6) ){
                layer.msg(JSON.stringify("请输入正确的数字"));
                $('.layui-laypage-btn').click();
                return;
            }else {
                if(data.score1 > 50 || data.score1 ==""){
                    layer.msg(JSON.stringify("修改失败,分数不能大于50且不能为空"));
                    $('.layui-laypage-btn').click();
                    return;
                }else if( (data.score2 > 10 || data.score2 ==="") ||
                    (data.score3 > 10 || data.score3 ==="") ||
                    (data.score4 > 10 || data.score4 ==="") ||
                    (data.score5 > 10 || data.score5 ==="") ||
                    (data.score6 > 10 || data.score6 ==="")
                ){
                    layer.msg(JSON.stringify("修改失败,分数不能大于10且不能为空"));
                    $('.layui-laypage-btn').click();
                    return;
                }else {
                    $.ajax({
                        url: '/classreply/stuupd',
                        type: 'post',
                        data: {
                            srid:data.srid,
                            score1:data.score1,
                            score2:data.score2,
                            score3:data.score3,
                            score4:data.score4,
                            score5:data.score5,
                            score6:data.score6,
                            remark:data.remark
                        },
                        dataType: 'json',
                        success:function(data){
                            if(data){
                                layer.msg(JSON.stringify("修改成功"));
                                $('.layui-laypage-btn').click();
                            }
                        },
                    })
                }
            }
        });


    });
</script>
</html>